package com.hzsai.view;

import com.hzsai.service.PdfExportService;
import com.lowagie.text.Document;
import com.lowagie.text.pdf.PdfWriter;
import org.springframework.web.servlet.view.document.AbstractPdfView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;

/**
 * hzsai 2019/7/27
 * usage:
 **/
public class PdfView extends AbstractPdfView {

    private PdfExportService service = null;

    public PdfView(PdfExportService service) {
        setContentType("application/pdf");
        this.service = service;
    }

    @Override
    protected void buildPdfDocument(Map<String, Object> map, Document document,
                                    PdfWriter pdfWriter, HttpServletRequest httpServletRequest,
                                    HttpServletResponse httpServletResponse) throws Exception {
        service.make(map, document, pdfWriter, httpServletRequest, httpServletResponse);
    }
}
